home *** CD-ROM | disk | FTP | other *** search
- Path: mail2news.demon.co.uk!devmaccn.demon.co.uk
- From: Alan Griffiths <aGriffiths@ma.ccngroup.com>
- Newsgroups: comp.lang.c++
- Subject: Re: The STL and nested structures
- Date: Thu, 11 Apr 1996 10:14:08 GMT
- Organization: CCN Market Analysis
- Distribution: world
- Message-ID: <35564965wnr@ma.ccngroup.com>
- References: <marnoldDpn0HH.3z2@netcom.com> <4ju9q7$fa1$1@mhadg.production.compuserve.com> <316a26d7.2989288@news.cyberport.com>
- Reply-To: aGriffiths@ma.ccngroup.com
- X-NNTP-Posting-Host: devmaccn.demon.co.uk
- X-Broken-Date: Thursday, Apr 11, 1996 10.14.08 GMT
- X-Newsreader: Newswin Alpha 0.6
- X-Mail2News-Path: devmaccn.demon.co.uk
-
- In article: <marnoldDpn0HH.3z2@netcom.com> marnold@netcom.com (Matt Arnold) writes:
- >
- > tangent@cyberport.com (Warren Young) writes:
- >
- > >Alan Huff <74312.2300@CompuServe.COM> wrote:
- >
- > >>I am having a problem using the STL with structures defined within
- > >>a class definition. Consider the following code fragment.
- > >>
- > >>>#include <vector.h>
- > >>>class Bar {
- > >>> struct Foo {
- > >>> int value;
- > >>> };
- > >>>
- > >>> vector< Foo > fooContainer;
- > >>>}
- > >>
- > >>The compiler I am using (VC 4.1) refuses to compile. An error is
- > >>generated the says "'Foo' : undeclared identifier" at line 75 in
- > >>vector.h.
- >
- > >It _is_ undeclared, just as a variable local to a function foo() is
- > >undeclared in a function bar(). What you want to say is:
- >
- > >vector<Bar::Foo> fooContainer;
- >
- > This should not be necessary. Nested class Foo should be visible for
- > use in template member Bar::fooContainer. fooContainer is in Bar's
- > scope. There should be no problem referring to it within Bar.
- >
- > I think Visual C++ is broken on the above code. It compiles fine in
- > Borland C++.
-
- MSVC4 gets the name bindings wrong (and from the above enquiry so
- does 4.1). The work-around is to move the declaration of Foo to
- global, non-namespace scope and use a typedef within Bar. (I know
- that's horrid - but that's Microsoft!)
-
- > Is it true that STL is currently incorrectly implemented?
-
- Yes, In so far as there is no compiler that would support a correct
- implementation. There are various partial implementations for various
- compilers.
-
-
- Alan Griffiths | Also editor of: The ISDF Newsletter
- Senior Systems Consultant, | (An Association of C and C++ Users publication)
- CCN Group Limited. | (ISDF editor : isdf@octopull.demon.co.uk)
- (agriffiths@ma.ccngroup.com) | (For ACCU see : http://bach.cis.temple.edu/accu)
-
-